//
//  RootViewController.m
//  PhongThuyHuongNha
//
//  Created by Le Anh Tai on 9/28/13.
//  Copyright (c) 2013 Le Anh Tai. All rights reserved.
//

#import "RootViewController.h"
#import "MainViewController_iPad.h"
#import "MainViewController_iPhone.h"
#import "UIConstants.h"

#ifdef __TESTING__
#import "PhongThuy/Test.h"
#endif

@interface RootViewController ()

@end

@implementation RootViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    //
    _mainViewController = [self newMainViewController];
    
    //
    [self.view addSubview:_mainViewController.view];
    [self addChildViewController:_mainViewController];
#ifdef __TESTING__
    [Test test];
#endif
}

- (void)viewWillLayoutSubviews
{
    [super viewWillLayoutSubviews];
    
    NSInteger distantTop = 0;
    if (IS_SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_IOS7)
    {
        distantTop = 20;
    }
    
    _mainViewController.view.frame = RECT(0, distantTop, self.view.width, self.view.height - distantTop);
}

- (MainViewController *)newMainViewController
{
    return nil;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
